package com.chainyoung.component_tmperson.ui.mvp.model;

import com.chainyoung.common.appcommon.entity.UploadFile;
import com.chainyoung.common.base.CommonSubscriber;
import com.chainyoung.common.di.scope.ActivityScope;
import com.chainyoung.common.integration.IRepositoryManager;
import com.chainyoung.common.mvp.BaseModel;
import com.chainyoung.common.utils.RxUtils;
import com.chainyoung.common.utils.UpLoadUtils;
import com.chainyoung.component_tmperson.api.PersonService;
import com.chainyoung.component_tmperson.entity.Bank;
import com.chainyoung.component_tmperson.entity.PurseAddr;
import com.chainyoung.component_tmperson.ui.mvp.contract.BindRecieveAccountContract;
import com.chainyoung.component_tmperson.ui.mvp.contract.WalletAddrContract;

import java.util.List;
import java.util.TreeMap;

import javax.inject.Inject;

import io.reactivex.Flowable;
import okhttp3.RequestBody;

@ActivityScope
public class SetRecieveAccountModel extends BaseModel implements BindRecieveAccountContract.Model {

    @Inject
    SetRecieveAccountModel(IRepositoryManager repositoryManager) {
        super(repositoryManager);

    }



    @Override
    public Flowable<String> setReceiveAccount(TreeMap<String, Object> map) {
        return mRepositoryManager.obtainRetrofitService(PersonService.class)
                .setRecieveAccount(map)
                .compose(RxUtils.<String>handleResult());
    }

    @Override
    public Flowable<List<Bank>> getBanks() {
        return mRepositoryManager.obtainRetrofitService(PersonService.class)
                .getBanks()
                .compose(RxUtils.<List<Bank>>handleResult());
    }

    @Override
    public Flowable<UploadFile> upLoadCodeImg(RequestBody params) {
        return mRepositoryManager.obtainRetrofitService(PersonService.class)
                .upLoadImage(params)
                .compose(RxUtils.<UploadFile>handleResult());
    }
}